package com.study.rabbit.mqtest;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class Consumer3 {
    @RabbitListener(queues = "fanout.A")
    public void getMassageFromQueueA(String msg, Channel channel, Message message) throws IOException {
        System.out.println("消费者A接收到消息："+msg);
        //手动ack
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

    @RabbitListener(queues = "fanout.B")
    public void getMassageFromQueueB(String msg, Channel channel, Message message) throws IOException {
        System.out.println("消费者B接收到消息："+msg);
        //手动ack
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

    @RabbitListener(queues = "fanout.C")
    public void getMassageFromQueueC(String msg, Channel channel, Message message) throws IOException {
        System.out.println("消费者C接收到消息："+msg);
        //手动ack
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }

}

